home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / GAMES / P_ROBO31 / FOO.PR < prev    next >
Text File  |  1989-10-23  |  2KB  |  61 lines

  1. (**************************************************************************)
  2. (*                             W A R N I N G                              *)
  3. (*                                                                        *)
  4. (*  This Robot has NOT been designed to take advantage of the advanced    *)
  5. (*  features of P-ROBOTS, such as, Shields, Fuel, Teams or Obstructions.  *)
  6. (**************************************************************************)
  7.  
  8.   PROCEDURE FOO;
  9.  
  10.     { Based on C-Robot FOO : programmed by OBI-ONE }
  11.  
  12.   VAR
  13.     drv_dir        : Integer; { drive direction }
  14.     scn_dir        : Integer; { scan direction }
  15.     Range          : Integer; { range to oponent }
  16.     found          : Integer; { foe found ? }
  17.     x, y           : Integer; { current location }
  18.  
  19.   BEGIN {FOO main}
  20.     drv_dir := Random(360); { initialize }
  21.     scn_dir := 0;
  22.     found := 0;
  23.     drive(drv_dir, 100);
  24.     
  25.     WHILE True DO BEGIN { main loop }
  26.       
  27.       { when close to wall, turn around at random.     }
  28.  
  29.       x := loc_x;
  30.       IF (x < 200) THEN
  31.         drv_dir := Random(90)
  32.       ELSE IF (x > 800) THEN
  33.         drv_dir := Random(90)+180;
  34.  
  35.       y := loc_y;
  36.       IF (y < 200) THEN
  37.         drv_dir := Random(90)+90
  38.       ELSE IF (y > 800) THEN
  39.         drv_dir := Random(90)+270;
  40.       
  41.       drive(drv_dir, 100);
  42.  
  43.       { scan every 20 degrees resolution. }
  44.       { if foe found, cannon it. }
  45.  
  46.       Range := scan(scn_dir, 10);
  47.       IF Range > 0 THEN
  48.         BEGIN
  49.           found := 1;
  50.           cannon(scn_dir, Range);
  51.         END
  52.       ELSE IF found > 0 THEN
  53.         BEGIN
  54.           found := 0;
  55.           scn_dir := scn_dir-30;
  56.         END
  57.       ELSE scn_dir := scn_dir+10;
  58.       
  59.     END; { end of main loop }
  60.   END; {FOO}
  61.